package cn.kaguyaever.dao.impl;

import cn.kaguyaever.dao.ProjectDao;
import cn.kaguyaever.entity.Project;
import cn.kaguyaever.entity.Vote;

import java.util.List;

public class ProjectDaoImpl extends BaseDao<Project> implements ProjectDao {

    public int createProject(Project project){
        String sql = "insert into project(`projectId`,`information`,`count`,`userId`) values(?,?,?,?)";
        return update(sql,project.getProjectId(),project.getInformation(),project.getCount(),project.getUserId());
    }

    public int setCount(Integer count,String projectId){
        String sql = "update project set count = ? where projectId = ?";
        return update(sql,count,projectId);
    }

    public Project queryProjectByProjectId(String projectId){
        String sql = "select `projectId`,`information`,`count`,`userId` from project where projectId = ?";
        return queryForOne(sql,projectId);
    }

    public Project queryProjectByUserId(Integer userId){
        String sql = "select `projectId`,`information`,`count`,`userId` from project where userId = ?";
        return queryForOne(sql,userId);
    }

    public int deleteProject(String projectId){
        String sql = "delete from project where projectId = ?";
        return update(sql,projectId);
    }
}
